package com.tiancheng.trade.payment.enums;

import com.tiancheng.trade.commom.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 通知消息类型
 *
 * @author likailun
 * @date 2021/03/24
 */
@Getter
@AllArgsConstructor
public enum NotifyTypeEnum implements BaseEnum<String> {

    PAY_RESULT("pay_result", "支付结果"),
    REFUND_RESULT("refund_result", "退款结果")
    ;

    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<NotifyTypeEnum> found = Arrays.stream(NotifyTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }
}
